﻿using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ElectricFence : MonoBehaviour
{
    private Sprite[] electricSptites;
    public SeqAction changeAction = new() { intervalTime = 2f / 25f };

    private SpriteRenderer[] electricSRs;
    private readonly Dictionary<string, Sprite> dictSprites = new();
    private void Awake()
    {
        electricSptites = new Sprite[] { ResourcesPool.Sprites.GetValueOrDefault("魂-电网-电1"), ResourcesPool.Sprites.GetValueOrDefault("魂-电网-电2") };
        electricSRs = GetComponentsInChildren<SpriteRenderer>();
    }
    void Start()
    {

    }

    void Update()
    {

    }
    private void FixedUpdate()
    {
        changeAction.Update((SeqAction seq) =>
        {
            int index = seq.seqNo % electricSptites.Length;
            foreach (SpriteRenderer renderer in electricSRs)
            {
                renderer.sprite = electricSptites[index];
            }
        });
    }
}
